package cn.changein.framework.api.setting.hotNotice.controller;

import cn.changein.framework.base.controller.BaseController;
import cn.changein.framework.base.pojo.page.PageInfo;
import cn.changein.framework.kernel.model.response.ResponseData;
import cn.changein.framework.model.setting.hotNotice.entity.HotNotice;
import cn.changein.framework.model.setting.hotNotice.model.params.HotNoticeParam;
import cn.changein.framework.model.setting.hotNotice.model.result.HotNoticeResult;
import cn.changein.framework.service.setting.hotNotice.HotNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("apiHotNoticeController")
@RequestMapping("/api/hotNotice")
public class ApiHotNoticeController extends BaseController {
    @Autowired
    private HotNoticeService hotNoticeService;


    /**
     * 首页中获取热门公告列表(即：字段热门公告为1的数据)
     *
     * @param hotNoticeParam
     * @return
     */
    @RequestMapping("/getHomepageNotice")
    @ResponseBody
    public List<HotNoticeResult> getHomepageNotice(HotNoticeParam hotNoticeParam) {
        hotNoticeParam.setHotStatus(1);
        return this.hotNoticeService.findListBySpec(hotNoticeParam);
    }

    /**
     * 首页中 更多按钮展示的公告列表
     *
     * @param hotNoticeParam
     * @return
     */
    @RequestMapping("/getHotNoticeList")
    @ResponseBody
    public PageInfo getHotNoticeList(@RequestBody HotNoticeParam hotNoticeParam) {
        return this.hotNoticeService.findPageBySpec(hotNoticeParam);
    }

    /**
     * 获取详情接口-通过id查询
     *
     * @param hotNoticeParam
     * @return
     */
    @RequestMapping("/getHotNoticeDetail")
    @ResponseBody
    public ResponseData getHotNoticeDetail(@RequestBody HotNoticeParam hotNoticeParam) {
        HotNotice detail = this.hotNoticeService.getById(hotNoticeParam.getId());
        return ResponseData.success(detail);
    }

}
